package cn.lg.soar.system.monitor.entity;

import cn.lg.soar.database.base.entity.ITenantEntity;
import cn.lg.soar.database.handler.IgnoreFillHandle;
import cn.lg.soar.database.handler.type.base.DynamicJsonTypeHandler;
import cn.lg.soar.database.translate.TranslateByEntity;
import cn.lg.soar.system.auth.entity.User;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import eu.bitwalker.useragentutils.DeviceType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;

/**
 * @author luguoxiang
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
@Getter
@Setter
@Accessors(chain = true)
@ApiModel(value = "操作日志", description = "日志对象")
@TableName("lg_sys_log")
public class OperationLog implements ITenantEntity, IgnoreFillHandle {

    @TableId
    private Long id;

    @ApiModelProperty("租户id")
    private Integer tenantId;

    @TranslateByEntity(value = User.class, label = "nickname")
    @ApiModelProperty("操作者（谁）")
    private Long userId;

    @ApiModelProperty("操作者ip（何地）")
    private String userIp;

    @ApiModelProperty("执行开始时间（何时）")
    private LocalDateTime datetime;

    @ApiModelProperty("操作（做了什么）")
    private String operate;

    @ApiModelProperty("哪个接口")
    private String path;

    @ApiModelProperty("终端类型")
    private DeviceType deviceType;

    @TableField("`system`")
    @ApiModelProperty("用户系统")
    private String system;

    @ApiModelProperty("用户浏览器")
    private String browser;

    @ApiModelProperty("详情（数据）")
    @TableField(value = "`data`", typeHandler = DynamicJsonTypeHandler.class)
    private Object data;

    @ApiModelProperty("数据类型")
    private String dataType;

    @ApiModelProperty("数据id")
    private String dataId;

}
